//JavaScript Doccument
var app = Common.initApp(['ngAnimate', 'ui.bootstrap', 'angular.filter']);
Common.initDirective(app);//初始化自定义指令
File.init(app);
app.controller('gengratefileidController', ['$scope', '$http', 
    function ($scope, $http ) {		
        $scope.gengratefileid = {};
        $scope.cleargengrateFileId = function() {
            $scope.gengratefileid = {};
        }

        //设置form业务表单信息
        $scope.fillGengrateFileId = function(data) {
            if (data) { //设置json格式数据到form表单中
                $scope.gengratefileid = data;
            }
        };
        console.log("xh:"+$scope.XH);
        //查询渲染填充数据到form表单(用于修改信息前的查询渲染数据)
        if ($scope.XH && $scope.XH != '') {//业务主键不为空,查询填充数据
            Common.send($scope, $http , {
                method : "POST",
                url : Common.webRoot() + '/szboanda/hbdc/gwgl/fwgl/controller/fwglworkflowmotioncontroller/getFileId',
                data : {"XH":$scope.XH, "LCLX": $scope.LCLX},
                success : function(response) {
                    console.log(response)
                    $scope.gengratefileid.XH = $scope.XH;
                    $scope.gengratefileid.LCLX = $scope.LCLX;
                    $scope.fillGengrateFileId(response.data);//返回查询结果集,渲染填充数据到form表单
                }
            });
        }else{
			$scope.gengratefileid.XH_TEMP = $scope.XH_TEMP;
		}


        //保存按钮绑定事件方法
        $scope.saveGengrateFileId = function() {
            $scope.gengratefileid.XH = $scope.XH;
            //验证"*"的必须填写，否则无法提交
            if(!Common.validate()) {
                return;
            }

            //添加处理逻辑
            var saveConfig = {
                url : Common.webRoot() + '/szboanda/hbdc/gwgl/fwgl/controller/fwglworkflowmotioncontroller/generateFileId',
                method : 'POST',
                showTips : true,
                data : JSON.stringify($scope.gengratefileid),
            success : function (response) {
                var data = response.data;
                if (data.model) {
                    $scope.fillGengrateFileId(data.model);
                }
            },
            error : function(response) {
                throw new Error('请求[' + saveConfig.url + ']出错,[' + response + ']')
            }
        };
            Common.send($scope, $http, saveConfig);
        };

    }]);
